package com.qianyu.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qianyu.project.entity.SystemAuthority;
import com.qianyu.project.mapper.provider.base.SystemAuthorityMapperProvider;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author gs
 * @since 2020-12-23
 */
@Repository
public interface SystemAuthorityMapper extends BaseMapper<SystemAuthority> {
    @Select("select * from system_authority where id not in (select sa.id from flow f ,system_authority sa where f.moduleId=sa.id and f.isvalid=1 )")
    List<SystemAuthority> listAndFlow();

    @Select("select * from system_authority where id not in (select * from (select sa.id from flow f ,system_authority sa where f.moduleId=sa.id and f.isvalid=1 ) s where s.id not in (#{value})  )\n")
    List<SystemAuthority> getUpdateauthority(Integer moduleid);

    @SelectProvider(type = SystemAuthorityMapperProvider.class,method = "selectByRole")
    List<SystemAuthority> selectByRole(String role);

    @SelectProvider(type = SystemAuthorityMapperProvider.class,method = "selectRootByRole")
    List<SystemAuthority> selectRootByRole(String role);
}
